package com.example.teaching_server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;

import java.time.LocalDateTime;

/**
 * 活动签到图片实体类
 * 存储活动签到时上传的图片信息
 */
@Getter
@Setter
@ToString(exclude = {"checkin"})
@EqualsAndHashCode(of = "id")
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "activity_checkin_images", indexes = {
        @Index(name = "idx_checkin_id", columnList = "checkin_id")
})
public class ActivityCheckinImageEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "checkin_id", nullable = false)
    @NotNull(message = "签到记录ID不能为空")
    private Long checkinId;

    @Column(name = "image_url", nullable = false, length = 500)
    @NotBlank(message = "图片URL不能为空")
    private String imageUrl;

    @Column(name = "description", length = 200)
    private String description;

    @Column(name = "sort_order")
    @Builder.Default
    private Integer sortOrder = 0;

    @CreationTimestamp
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "checkin_id", insertable = false, updatable = false)
    private ActivityCheckinEntity checkin;
}
